package demo2;

import java.util.Scanner;

class Student /*implements Cloneable*/{
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Test {


    public static int func(int a) {
        try{
            int ret=a/10;
            return ret;
        }catch(NullPointerException e) {
            System.out.println("NullPointerException");
        }finally{
            return 99;
        }
    }

    public static void main(String[] args) {
        System.out.println(func(10));
    }

    public static void main3(String[] args) {

        try (Scanner sc = new Scanner(System.in)) {
            int a = sc.nextInt();
            System.out.println(a / 0);
        } catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("捕获了ArithmeticException异常");
        } finally {
            System.out.println("finally执行了");
        }
    }

    public static void main2(String[] args) throws CloneNotSupportedException {
        Scanner sc=new Scanner(System.in);

        try {
            Student student =new Student();
            Student student1=(Student)student.clone();
        }catch(CloneNotSupportedException e) {
            e.printStackTrace();
            System.out.println("程序员手动处理异常");
        }catch(Exception e) {
            System.out.println("捕获Exception异常");
        }finally {
            System.out.println("finally执行了");
            sc.close();
        }

    }


    public static void main1(String[] args) {
        try {
            System.out.println(10/0);

        }catch(ArithmeticException e) {
            System.out.println("捕获到了一个Arithmetic异常，并且可以开始处理了！");
        }
        System.out.println("处理完异常后继续执行");
    }
}
